package com.mygdx.game.own;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Assets {

    public static Texture background;
    public static TextureRegion backgroundRegion;
    public static Texture items;
    public static Texture menus;

    public static TextureRegion mainMenu;
    public static TextureRegion pauseMenu;
    public static TextureRegion ready;
    public static TextureRegion gameOver;
    //高分榜
    public static TextureRegion highScoresRegion;
    public static Texture logo;
    public static TextureRegion soundOn;
    public static TextureRegion soundOff;
    public static TextureRegion arrow;
    public static TextureRegion pause;
    public static TextureRegion spring;
    public static TextureRegion castle;
    //树木
    public static Texture tree;


    public static Animation coinAnim;
    public static Animation bobJump;
    public static Animation bobFall;
    public static TextureRegion bobHit;
    public static Animation squirrelFly;
    public static TextureRegion platform;
    public static Animation brakingPlatform;
    public static BitmapFont font;

    public static Music music;
    public static Sound jumpSound;
    public static Sound highJumpSound;
    public static Sound hitSound;
    public static Sound coinSound;
    public static Sound clickSound;

    public static Texture loadTexture(String file){
        return new Texture(Gdx.files.internal(file));
    }
    public static void load(){
        background = loadTexture("data/klbg.png");
        backgroundRegion = new TextureRegion(background, 0, 0, 320, 480);

        items = loadTexture("data/items.png");
        menus = loadTexture("data/kl/menus.png");
        mainMenu = new TextureRegion(Assets.menus, 60, 10, 240, 80);

        highScoresRegion = new TextureRegion(Assets.menus, 20, 70, 240, 100 );

        pauseMenu = new TextureRegion(items, 224, 128, 192, 96);
        ready = new TextureRegion(items, 320, 224, 192, 32);
        gameOver = new TextureRegion(items, 352, 256, 160, 96);

        //logo = loadTexture("data/kl/logo.png");
        soundOff = new TextureRegion(items, 0, 0, 64, 64);
        soundOn = new TextureRegion(items, 64, 0, 64, 64);
        arrow = new TextureRegion(items, 0, 64, 64, 64);
        pause = new TextureRegion(items, 64, 64, 64, 64);

        tree = loadTexture("data/tree.png");

        bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32), new TextureRegion(items, 32, 128, 32, 32));
        bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32), new TextureRegion(items, 96, 128, 32, 32));

        music = Gdx.audio.newMusic(Gdx.files.internal("data/music.mp3"));
        if(Settings.soundEnabled)music.play();
    }

    public void playSound(Sound sound){
        if(Settings.soundEnabled){
            sound.play(1);
        }
    }
}
